In [2]:
from qutip import *
from numpy import sqrt
from numpy import math
factorial = math.factorial
In [3]:
# from van Enk NotesBS.pdf
N = 5 # use a 5-dim space for now, enlarge as needed
a1 = tensor(destroy(N),qeye(N)) # a1 acts on photon 1
a2 = tensor(qeye(N),destroy(N)) # a2 acts on photon 2
a3 = (a1 + 1j*a2)/sqrt(2) # output a3
a4 = (1j*a1 + a2)/sqrt(2) # output a4
In [4]:
def input(n,m,N):
an = a1.dag()
am = a2.dag()
psi_in = 1/sqrt(factorial(n)) * (an**n) * 1/sqrt(factorial(m)) * (am**m) * tensor(basis(N,0),basis(N,0))
return psi_in.unit()
In [5]:
input(0,1,N)
Out[5]:
In [131]:
a3 = tensor(destroy(N),identity(N))
a4 = tensor(identity(N),destroy(N))
In [132]:
def output(n,m,N):
"""Based on van Enk, NotesBS.pdf point 19"""
an = (a3.dag() + 1j*a4.dag())/sqrt(2)
am = (1j*a3.dag() + a4.dag())/sqrt(2)
psi_out = 1/sqrt(factorial(n)) * (an**n) * 1/sqrt(factorial(m)) * (am**m) * tensor(basis(N,0),basis(N,0))
return psi_out
In [133]:
psi01 = 1/sqrt(2)*(1j*tensor(basis(N,1),basis(N,0)) + tensor(basis(N,0),basis(N,1)))
In [134]:
psi01 == output(0,1,N)
Out[134]:
In [135]:
psi11 = 1/sqrt(2)*(-1j*tensor(basis(N,2),basis(N,0)) - 1j*tensor(basis(N,0),basis(N,2)))
Oddly, this isn't right yet, but it's off by a sign error:
In [160]:
psi11 == -output(1,1,N)
Out[160]:
In [163]:
test = 1/2 * (a3.dag() + 1j*a4.dag()) * (1j*a3.dag() + a4.dag()) * tensor(basis(N,0),basis(N,0))
test.full
Out[163]:
In [ ]: